import Utils from 'common/utils';
import { observable, computed, action } from 'mobx';


export default class Text {
  @observable videoWidth = 200;
  @observable videoHeight = 200;
  @observable videoImg = '';
  @observable autoplay = true;
  @observable src = '//cloud.video.taobao.com/play/u/2893966855/p/2/e/6/t/1/50008342924.mp4';


  constructor({ ...data }) {
    this.init({
      ...data,
      label: '图片',
      type: 'image',
    });
  }

  @computed get styleWrapper() {
    return {
      width: this.videoWidth,
      height: this.videoHeight,
      src: this.src,
      autoPlay: this.autoplay,

    };
  }


  @action init({ label, ...other }) {
    this.label = label;
    this.title = Utils.guid(label);
    Object.keys(other).map(key => {
      this[key] = other[key];
    });
  }

  @action setAttr(key, val) {
    this[key] = val;
  }

  @action setAuto() {
    this.autoplay = !this.autoplay;
  }

}




